package sis.utiltest;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-08-01 10:33
 * @notify
 * @version 1.0
 */

import junit.framework.TestCase;
import sis.util.LineWriter;
import sis.util.TestUtil;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class LineWriterTest extends TestCase {

    public void testMultipleRecords() throws IOException {
        //向这个文件写入内容
        final String file = "LineWriterTest.testCreate.txt";
        try {
            //给出 目标文件 和写入内容
            LineWriter.write(file, new String[]{"a", "b"});
            BufferedReader reader = null;
            try {
                //字符流输出流缓冲区
                reader = new BufferedReader(new FileReader(file));
                //断言第一行内容
                assertEquals("a", reader.readLine());
                //断言第二行内容
                assertEquals("b", reader.readLine());
                //断言第三行为null
                assertNull(reader.readLine());
            } finally {
                //关闭流
                if (reader != null) {
                    reader.close();
                }
            }
        } finally {
            //删除测试文件
            //  TestUtil.delete(file);
        }
    }
}
